// 权限
export const powerArray = {
  // n7-3  教具管理员； n6-3 图书管理员；n9-3 物料管理员； n12-1-3 餐品管理员；
  powerTop: {
    is_all: 1, // 字段可查看全站数据
    power: [],
    otherPower: []
  },
  // 图书
  powerBook: {
    is_all: 1,
    power: ['n6-3'],
    otherPower: []
  },
  // 物料
  powerMateriel: {
    is_all: 1,
    power: ['n9-3'],
    otherPower: []
  },
  // 教具
  powerTeacher: {
    is_all: 1,
    power: ['n7-3'],
    otherPower: []
  },
  // 论坛
  powerForum: {
    is_all: 1,
    power: ['n7-3'],
    otherPower: []
  },
  // 区角
  powerCorner: {
    is_all: 1,
    power: ['n14-1-2'],
    otherPower: []
  },
  // 餐品
  powerFood: {
    is_all: 1,
    power: ['n12-1-3'],
    otherPower: []
  }
}

export function powerArrayFn (date, type) {
  // powerArray
  let state = false
  if (date.id === 1) {
    state = true
  } else {
    if (date.is_all === 1 && type === 'powerTop') {
      state = true
    } else {
      let powerState = JSON.parse(date.power)
      for (let i in powerArray[type].power) {
        if (powerState.indexOf(powerArray[type].power[i]) !== -1) {
          state = true
        }
      }
    }
  }
  return state
}
